module hybrid_coord_ecmwf_mod

  use const_mod

  implicit none

  private

  public hybrid_coord_ecmwf_l50
  public hybrid_coord_ecmwf_l90

contains

  subroutine hybrid_coord_ecmwf_l50(p0, ptop, hyai, hybi)

    real(r8), intent(out) :: p0
    real(r8), intent(out) :: ptop
    real(r8), intent(out) :: hyai(50)
    real(r8), intent(out) :: hybi(50)

    hyai = [20.006149    , & !  1
            43.297810    , & !  2
            75.346230    , & !  3
            115.082146   , & !  4
            161.897491   , & !  5
            215.896912   , & !  6
            278.005798   , & !  7
            350.138184   , & !  8
            435.562286   , & !  9
            539.651489   , & ! 10
            668.615540   , & ! 11
            828.398987   , & ! 12
            1026.366943  , & ! 13
            1271.644531  , & ! 14
            1575.537842  , & ! 15
            1952.054443  , & ! 16
            2418.549805  , & ! 17
            2996.526611  , & ! 18
            3712.626221  , & ! 19
            4599.856934  , & ! 20
            5699.114746  , & ! 21
            6998.388184  , & ! 22
            8507.411133  , & ! 23
            10181.707031 , & ! 24
            11883.089844 , & ! 25
            13442.915039 , & ! 26
            14736.354492 , & ! 27
            15689.206055 , & ! 28
            16266.609375 , & ! 29
            16465.003906 , & ! 30
            16297.620117 , & ! 31
            15791.597656 , & ! 32
            14985.269531 , & ! 33
            13925.519531 , & ! 34
            12665.294922 , & ! 35
            11261.230469 , & ! 36
            9771.406250  , & ! 37
            8253.210938  , & ! 38
            6761.339844  , & ! 39
            5345.917969  , & ! 40
            4050.718750  , & ! 41
            2911.570312  , & ! 42
            1954.804688  , & ! 43
            1195.890625  , & ! 44
            638.148438   , & ! 45
            271.625000   , & ! 46
            72.062500    , & ! 47
            0.000000     , & ! 48
            0.000000     , & ! 49
            0.000000]        ! 50

    hybi = [0.000000     , & !  1
            0.000000     , & !  2
            0.000000     , & !  3
            0.000000     , & !  4
            0.000000     , & !  5
            0.000000     , & !  6
            0.000000     , & !  7
            0.000000     , & !  8
            0.000000     , & !  9
            0.000000     , & ! 10
            0.000000     , & ! 11
            0.000000     , & ! 12
            0.000000     , & ! 13
            0.000000     , & ! 14
            0.000000     , & ! 15
            0.000000     , & ! 16
            0.000000     , & ! 17
            0.000000     , & ! 18
            0.000000     , & ! 19
            0.000000     , & ! 20
            0.000000     , & ! 21
            0.000000     , & ! 22
            0.000100     , & ! 23
            0.000673     , & ! 24
            0.003163     , & ! 25
            0.009292     , & ! 26
            0.020319     , & ! 27
            0.036975     , & ! 28
            0.059488     , & ! 29
            0.087895     , & ! 30
            0.122004     , & ! 31
            0.161442     , & ! 32
            0.205703     , & ! 33
            0.254189     , & ! 34
            0.306235     , & ! 35
            0.361145     , & ! 36
            0.418202     , & ! 37
            0.476688     , & ! 38
            0.535887     , & ! 39
            0.595084     , & ! 40
            0.653565     , & ! 41
            0.710594     , & ! 42
            0.765405     , & ! 43
            0.817167     , & ! 44
            0.864956     , & ! 45
            0.907716     , & ! 46
            0.944213     , & ! 47
            0.972985     , & ! 48
            0.992281     , & ! 49
            1.000000]        ! 50

    p0 = 1d5 ! Pa
    hyai = hyai / p0
    ptop = p0 * hyai(1)

  end subroutine hybrid_coord_ecmwf_l50

  subroutine hybrid_coord_ecmwf_l90(p0, ptop, hyai, hybi)

    real(r8), intent(out) :: p0
    real(r8), intent(out) :: ptop
    real(r8), intent(out) :: hyai(91)
    real(r8), intent(out) :: hybi(91)

    hyai = [        &
      2.000040    , & !  1
      3.980832    , & !  2
      7.387186    , & !  3
      12.908319   , & !  4
      21.413612   , & !  5
      33.952858   , & !  6
      51.746601   , & !  7
      76.167656   , & !  8
      108.715561  , & !  9
      150.986023  , & ! 10
      204.637451  , & ! 11
      271.356506  , & ! 12
      352.824493  , & ! 13
      450.685791  , & ! 14
      566.519226  , & ! 15
      701.813354  , & ! 16
      857.945801  , & ! 17
      1036.166504 , & ! 18
      1237.585449 , & ! 19
      1463.163940 , & ! 20
      1713.709595 , & ! 21
      1989.874390 , & ! 22
      2292.155518 , & ! 23
      2620.898438 , & ! 24
      2976.302246 , & ! 25
      3358.425781 , & ! 26
      3767.196045 , & ! 27
      4202.416504 , & ! 28
      4663.776367 , & ! 29
      5150.859863 , & ! 30
      5663.156250 , & ! 31
      6199.839355 , & ! 32
      6759.727051 , & ! 33
      7341.469727 , & ! 34
      7942.926270 , & ! 35
      8564.624023 , & ! 36
      9208.305664 , & ! 37
      9873.560547 , & ! 38
      10558.881836, & ! 39
      11262.484375, & ! 40
      11982.662109, & ! 41
      12713.897461, & ! 42
      13453.225586, & ! 43
      14192.009766, & ! 44
      14922.685547, & ! 45
      15638.053711, & ! 46
      16329.560547, & ! 47
      16990.623047, & ! 48
      17613.281250, & ! 49
      18191.029297, & ! 50
      18716.968750, & ! 51
      19184.544922, & ! 52
      19587.513672, & ! 53
      19919.796875, & ! 54
      20175.394531, & ! 55
      20348.916016, & ! 56
      20434.158203, & ! 57
      20426.218750, & ! 58
      20319.011719, & ! 59
      20107.031250, & ! 60
      19785.357422, & ! 61
      19348.775391, & ! 62
      18798.822266, & ! 63
      18141.296875, & ! 64
      17385.595703, & ! 65
      16544.585938, & ! 66
      15633.566406, & ! 67
      14665.645508, & ! 68
      13653.219727, & ! 69
      12608.383789, & ! 70
      11543.166992, & ! 71
      10471.310547, & ! 72
      9405.222656 , & ! 73
      8356.252930 , & ! 74
      7335.164551 , & ! 75
      6353.920898 , & ! 76
      5422.802734 , & ! 77
      4550.215820 , & ! 78
      3743.464355 , & ! 79
      3010.146973 , & ! 80
      2356.202637 , & ! 81
      1784.854614 , & ! 82
      1297.656128 , & ! 83
      895.193542  , & ! 84
      576.314148  , & ! 85
      336.772369  , & ! 86
      162.043427  , & ! 87
      54.208336   , & ! 88
      6.575628    , & ! 89
      0.003160    , & ! 90
      0.000000      & ! 91
    ]
    hybi = [        &
      0.000000    , & !  1
      0.000000    , & !  2
      0.000000    , & !  3
      0.000000    , & !  4
      0.000000    , & !  5
      0.000000    , & !  6
      0.000000    , & !  7
      0.000000    , & !  8
      0.000000    , & !  9
      0.000000    , & ! 10
      0.000000    , & ! 11
      0.000000    , & ! 12
      0.000000    , & ! 13
      0.000000    , & ! 14
      0.000000    , & ! 15
      0.000000    , & ! 16
      0.000000    , & ! 17
      0.000000    , & ! 18
      0.000000    , & ! 19
      0.000000    , & ! 20
      0.000000    , & ! 21
      0.000000    , & ! 22
      0.000000    , & ! 23
      0.000000    , & ! 24
      0.000000    , & ! 25
      0.000000    , & ! 26
      0.000000    , & ! 27
      0.000000    , & ! 28
      0.000000    , & ! 29
      0.000000    , & ! 30
      0.000000    , & ! 31
      0.000000    , & ! 32
      0.000000    , & ! 33
      0.000000    , & ! 34
      0.000014    , & ! 35
      0.000055    , & ! 36
      0.000131    , & ! 37
      0.000279    , & ! 38
      0.000548    , & ! 39
      0.001000    , & ! 40
      0.001701    , & ! 41
      0.002765    , & ! 42
      0.004267    , & ! 43
      0.006322    , & ! 44
      0.009035    , & ! 45
      0.012508    , & ! 46
      0.016860    , & ! 47
      0.022189    , & ! 48
      0.028610    , & ! 49
      0.036227    , & ! 50
      0.045146    , & ! 51
      0.055474    , & ! 52
      0.067316    , & ! 53
      0.080777    , & ! 54
      0.095964    , & ! 55
      0.112979    , & ! 56
      0.131935    , & ! 57
      0.152934    , & ! 58
      0.176091    , & ! 59
      0.201520    , & ! 60
      0.229315    , & ! 61
      0.259554    , & ! 62
      0.291993    , & ! 63
      0.326329    , & ! 64
      0.362203    , & ! 65
      0.399205    , & ! 66
      0.436906    , & ! 67
      0.475016    , & ! 68
      0.513280    , & ! 69
      0.551458    , & ! 70
      0.589317    , & ! 71
      0.626559    , & ! 72
      0.662934    , & ! 73
      0.698224    , & ! 74
      0.732224    , & ! 75
      0.764679    , & ! 76
      0.795385    , & ! 77
      0.824185    , & ! 78
      0.850950    , & ! 79
      0.875518    , & ! 80
      0.897767    , & ! 81
      0.917651    , & ! 82
      0.935157    , & ! 83
      0.950274    , & ! 84
      0.963007    , & ! 85
      0.973466    , & ! 86
      0.982238    , & ! 87
      0.989153    , & ! 88
      0.994204    , & ! 89
      0.997630    , & ! 90
      1.000000      & ! 91
    ]

    p0 = 1d5 ! Pa
    hyai = hyai / p0
    ptop = p0 * hyai(1)

  end subroutine hybrid_coord_ecmwf_l90

end module hybrid_coord_ecmwf_mod
